#include <iostream>
using namespace std;

//立方体类设计
//  1、创建立方体类
//  2、设计属性
//  3、设计行为   获取立方体的面积和体积
//  4、分别利用全局函数和成员函数，判断两个立方体是否相等

class Cube
{
private:
    int length;
    int width;
    int high;

public:
    //设置长
    void setLength(int Length)
    {
        length = Length;
    }
    
    //获取长
    int getLength()
    {
        return length;
    }
    
    //设置宽
    void setWidth(int Width)
    {
        width = Width;
    }
    
    //获取宽
    int getWidth()
    {
        return width;
    }
    
    //设置高
    void setHigh(int High)
    {
        high = High;
    }
    
    //获取高
    int getHigh()
    {
        return high;
    }
    
    //获取面积
    int getS()
    {
        return 2 * width * length +
            2 * width * high + 2 * length * high;
    }
    
    //获取体积
    int getV()
    {
        return width * length * high;
    }

    //利用成员函数，判断两个立方体是否相同
    bool isSame(Cube& c)
    {
        return c.getHigh() == getHigh() &&
            c.getLength() == getLength() &&
            c.getWidth() == getWidth();
    }
};

//利用全局函数，判断两立方体是否相等
bool isSame(Cube& c1, Cube& c2)
{
    return c1.getHigh() == c2.getHigh() &&
        c1.getLength() == c2.getLength() &&
        c1.getWidth() == c2.getWidth();
}

int main()
{
    //创建一个立方体对象
    Cube c1;

    c1.setLength(10);
    c1.setHigh(5);
    c1.setWidth(6);

    cout << "c1的面积为：" << c1.getS() << endl;
    cout << "c1的体积为：" << c1.getV() << endl;
    cout << "c1的长为：" << c1.getLength() << endl;
    cout << "c1的宽为：" << c1.getWidth() << endl;
    cout << "c1的高为：" << c1.getHigh() << endl;

    //创建第二个立方体对象
    Cube c2;
    c2.setLength(10);
    c2.setHigh(5);
    c2.setWidth(6);

    cout << "利用全局函数判断的结果：" << endl;
    cout << (isSame(c1, c2) ? "c1与c2相等" : "c1与c2不相等") << endl;

    cout << "利用局部函数判断的结果：" << endl;
    cout << (c1.isSame(c2) ? "c1与c2相等" : "c1与c2不相等") << endl;

    return 0;
}